import { Controller, Post, UploadedFile, UseInterceptors } from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import { ApiConsumes, ApiBody, ApiTags } from '@nestjs/swagger';
import { UploadService } from './upload.service';
import { ApiFile } from './decorators/api-file.decorator';
import 'multer';
import { SkipResponseInterceptor } from 'src/common/interceptors/skip-response-interceptor.decorator';

@ApiTags('Upload')
@Controller('upload')
export class UploadController {
  constructor(private readonly uploadService: UploadService) {}

  @Post('image')
  @SkipResponseInterceptor()
  // @ApiFile('file', true,{
  //   dest: './uploads',
  // })
  @ApiFile('file', true, { storage: UploadService.getStorage() })
  uploadImage(@UploadedFile() file: Express.Multer.File) {
    return this.uploadService.getUploadedFileUrl(file);
  }
}
